package com.wwp.tbshop.view.fragment.category;

import android.os.SystemClock;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.wwp.tbshop.model.bean.CategoryInfo;
import com.wwp.tbshop.model.bean.CategoryTempBean;
import com.wwp.tbshop.model.bean.CategoryVo;
import com.wwp.tbshop.util.Constant;
import com.wwp.tbshop.view.adapter.ChildDressRvAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 楠GG on 2017/6/15.
 */

public class ChildDressFragment extends CategoryBaseFragment {

    private ChildDressRvAdapter mChildDressRvAdapter;
    private List<CategoryTempBean> mDatas = new ArrayList<>();
    private List<CategoryInfo> mCategoryInfoList = new ArrayList<>();

    @Override
    protected View onPostExcute() {
        RecyclerView rv = new RecyclerView(getActivity());
        rv.setLayoutManager(new LinearLayoutManager(getActivity()));
        mChildDressRvAdapter = new ChildDressRvAdapter(getActivity());
        mChildDressRvAdapter.setDatas(mCategoryInfoList);
        rv.setAdapter(mChildDressRvAdapter);
        return rv;
    }

    @Override
    public HeimaAsyncTask.Result doInBackground() {
        SystemClock.sleep(Constant.SLEEP_TIME);
        for (CategoryVo.CategoryBean bean  :mMap2.keySet() ) {
            if (mMap2.containsKey(bean) && bean.getParentId() == 5){

                List<CategoryVo.CategoryBean> categoryBeen = mMap2.get(bean);
                if(categoryBeen.size() != 0) {
                    List<CategoryInfo> transfore = transfore(bean, categoryBeen);
                    mCategoryInfoList.addAll(transfore);
                }
            }
        }
        return HeimaAsyncTask.Result.SUCCESS;
    }

}
